package com.bone.eventsweb.controller;
import java.util.Arrays;
import java.util.Map;
import com.bone.eventsweb.utils.PageUtils;
import com.bone.eventsweb.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.bone.eventsweb.entity.CarouselmapEntity;
import com.bone.eventsweb.service.CarouselmapService;


/**
 * 
 *
 * @author dkx
 * @email null
 * @date 2024-02-26 15:06:22
 */
@RestController
@RequestMapping("/eventsweb/carouselmap")
public class CarouselmapController {

    @Autowired
    private CarouselmapService carouselmapService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = carouselmapService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		CarouselmapEntity carouselmap = carouselmapService.getById(id);

        return R.ok().put("carouselmap", carouselmap);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public String save(@RequestBody CarouselmapEntity carouselmap){
        System.out.println(carouselmap);
        boolean flag = carouselmapService.save(carouselmap);
        if (flag){
            return "添加成功";
        }
        return "添加失败";
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody CarouselmapEntity carouselmap){
		carouselmapService.updateById(carouselmap);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		carouselmapService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
